<?php

/**
 * @author Terry & 千里孤坟
 * @copyright 2009
 */

class LangClass {
	public function __construct() {
		$this->id = -1;
		$this->name = "话术基类";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 50;
		$this->tp = 0;
		$this->bodds = 0;
	}
	
	//起始函数，特殊型
	public function start($a,$b,$atkid,$defid,$defer) {		
		CalHelper::cost_cal($a[$atkid],$this);
		$sk->action($a[$atkid]);		
	}
	
	//行动函数
	public function action($a) {	
					
	}
	
	public function pre_talk($a,$b){
		/**
		if($b->isboss == 1) {
			$_SESSION['show'] .= "<font color=red>话语无效</font><br>";
			$this->bodds = 0;
		}
		**/
		//排除正被说得者，被恶戏/诱惑者和中死约者
		if($b->talked == 1 || $b->atkafter_status[7]->on == 1 || $b->atkafter_status[10]->on == 1 || $b->defafter_status[5]->on == 1) {
			$_SESSION['show'] .= $b->name."已中其它话术，".$this->name."无效。<br>";
			$this->bodds = 0;
		}
		if($b->eventskill_status[19]->on == 1) {
			$_SESSION['show'] .= $b->name."混沌波动生效，".$this->name."完全无用。<br>";
			$this->bodds = 0;
		}

		return 1;
	}

}


class Tease extends LangClass {

	public function __construct() {
		$this->id = 279;
		$this->name = "悪戯";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 50;
		$this->tp = 50;
		$this->bodds = 30;
	}
	
	//起始函数，单体型
	public function start($a,$b,$atkid,$defid,$defer) {		
		
		$sk = clone $this;
		CalHelper::cost_cal($a[$atkid],$sk);
		$sk->action($a[$atkid],$defer);		
	}
	
	//行动函数
	public function action($a,$b) {
		if($b->before_status[0]->on == 1) {
			$_SESSION['show'] .= $a->name."压倒在".$b->name."身上，试图强吻<br>";
		} elseif($a->cid == 77) {
			$_SESSION['show'] .= $a->name."凑近".$b->name."耳边，手掌按在其身后的墙壁上道：<br>小姐你要让我负起责任的话，我可以负起来哦，你要跟我走！<br>";
			CalHelper::cgdisplay("wwolf_2.jpg");
		} else {
			$_SESSION['show'] .= $a->name."对".$b->name."说出一连串令人耳红心跳的情话。<br>";
		}
		$this->pre_talk($a,$b);
		if($b->gender == 1) {
			$b->atkskill_status[6]->on = 1;
			$_SESSION['show'] .= $b->name."怒斥".$a->name."道：我才没有那种嗜好，给我去死！<br>";
			return 0;
		}
		$tmp = mt_rand(1,100);
		if ($this->bodds < $tmp) {
			$b->atkskill_status[6]->on = 1;
			if($b->before_status[0]->on == 1) {
				$_SESSION['show'] .= $b->name."怒火攻心，脑袋奋力一顶，撞得".$a->name."满脸是血(追加行动)。乱数：".$tmp."<br>";
			} else {
				$_SESSION['show'] .= $b->name."顿时对".$a->name."露出憎恶的表情，杀气暴溢(追加行动)。乱数：".$tmp."<br>";
			}
			$b->done --;
			return 0;
		} else {
			$b->initvit=$b->vit;
			$b->vit=0;
			$b->before_status[40]->on = 1;
			$b->atkafter_status[7]->on = 1;
			$b->before_status[40]->committer = $a->uuid;
			$_SESSION['show'] .= $b->name."紧咬牙关，面色绯红，好似对".$a->name."下不了手了。<br>";
			return 1;
		}
	}
}

class Charm extends LangClass {

	public function __construct() {
		$this->id = 280;
		$this->name = "誘惑";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 50;
		$this->tp = 50;
		$this->bodds = 30;
	}
	
	//起始函数，单体型
	public function start($a,$b,$atkid,$defid,$defer) {		
		
		$sk = clone $this;
		CalHelper::cost_cal($a[$atkid],$sk);
		$sk->action_pretalk($a[$atkid],$defer);
		if(CalHelper::live_count($b) == 1) {
			$sk->action_onlyone($a[$atkid],$defer);
		} else {
			$sk->action($a[$atkid],$defer,$defid);
		}
	}
	
	//预台词输出
	public function action_pretalk($a,$b) {
		if($a->cid == 66) {
			$_SESSION['show'] .= $a->name."抬起裹着黑色丝袜的纤纤细腿，足尖顶着高跟鞋在".$b->name."面前来回晃动，仿佛暗示着什么<br>";
			CalHelper::cgdisplay("lili_1.jpg");
		} elseif($b->before_status[0]->on == 1) {
			$_SESSION['show'] .= $a->name."骑乘在".$b->name."脸上，露出放荡的笑容。<br>";
			if($a->cid == 37) {CalHelper::cgdisplay("violet_2.jpg");}
		} else {
			$_SESSION['show'] .= $a->name."吸吻着自己的指尖，指向".$b->name."作出挑逗手势。<br>";
		}
		$this->pre_talk($a,$b);
		if($b->gender == 0) {
			$a->before_status[44]->on = 1;
			$_SESSION['show'] .=$b->name."边后退边骂道：真脏，真恶心，不要靠近我！<br>";
		}

	}

	//失败台词输出
	public function action_failtalk($a,$b,$n) {
		if($b->before_status[0]->on == 1 && $b->gender == 1) {
			$_SESSION['show'] .=$b->name."闭上眼睛，尽力把握住了自己，没有被".$a->name."诱惑。<br>";
		} elseif($b->gender == 1) {
			$_SESSION['show'] .=$b->name."失望地摇了摇头。".$a->name."因自己的魅力不足受到了沉重打击。乱数：".$n."<br>";
		}
		$a->before_status[44]->on = 1;
	}

	//对方只有一人时的行动函数	
	public function action_onlyone($a,$b) {
		$tmp = mt_rand(1,100);
		if($this->bodds >= $tmp && $b->gender == 1) {
			$_SESSION['show'] .= $b->name."被".$a->name."的魅力打动，一副完全无所适从的样子(停止行动)。乱数".$tmp."<br>";
			$b->atkafter_status[10]->on = 1;
			$b->before_status[41]->on = 1;
		}
		else {
			$this->action_failtalk($a,$b,$tmp);
		}
	}

	//行动函数 $f:来自哪组 $t:到哪组
	public function action($a,$b,$fp) {
		$tmp = mt_rand(1,100);
		if($this->bodds >= $tmp && $b->gender == 1) {
			if(in_array($b,$_SESSION['a'])) {
				$f = &$_SESSION['a'];
				$t = &$_SESSION['b'];				
			}
			else {
				$f = &$_SESSION['b'];
				$t = &$_SESSION['a'];				
			}
			$_SESSION['show'] .= $b->name."一时晕晕乎乎不能自已，加入了".$a->name."的阵营。 乱数:".$tmp."<br>";
			$b->talked = 1;
			StatusHelper::str_up_20($b);
			StatusHelper::mgr_up_20($b);
			$b->atkafter_status[8]->on = 1;			
			$b->atkafter_status[8]->fp = $fp;
			$b->atkafter_status[8]->tp = count($t);
			$t[count($t)] = $b;
			$dummy = new Char;
			$dummy->hp = 0;
			$dummy->name = "占位";
			$dummy->isdummy = 1;
			$f[$fp] = $dummy;
		}
		else {
			$this->action_failtalk($a,$b,$tmp);
		}
	}
}

class BrainWash extends LangClass {

	public function __construct() {
		$this->id = 281;
		$this->name = "洗脑";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 70;
		$this->tp = 70;
		$this->bodds = 20;
	}
	
	//起始函数，单体型
	public function start($a,$b,$atkid,$defid,$defer) {		
		
		$sk = clone $this;
		CalHelper::cost_cal($a[$atkid],$sk);
		$sk->action($a[$atkid],$defer,$defid);		
	}
	
	//行动函数 $f:来自哪组 $t:到哪组
	public function action($a,$b,$fp) {
		$_SESSION['show'] .= $a->name."向".$b->name."灌输着各种猥琐的思想。<br>";
		$this->pre_talk($a,$b);
		$tmp = mt_rand(1,100);
		if($this->bodds >= $tmp) {
			if(in_array($b,$_SESSION['a'])) {
				$f = &$_SESSION['a'];
				$t = &$_SESSION['b'];				
			}
			else {
				$f = &$_SESSION['b'];
				$t = &$_SESSION['a'];				
			}
			$_SESSION['show'] .= $b->name."被洗脑，加入了".$a->name."的阵营！ 乱数:".$tmp."<br>";
			$b->talked = 1;
			$b->atkafter_status[6]->on = 1;			
			$b->atkafter_status[6]->fp = $fp;
			$b->atkafter_status[6]->tp = count($t);
			$t[count($t)] = $b;
			$dummy = new Char;
			$dummy->hp = 0;
			$dummy->name = "占位";
			$dummy->isdummy = 1;
			$f[$fp] = $dummy;
		}
		else {
			$_SESSION['show'] .= $b->name."听了".$a->name."的话勃然大怒，上去就是一个耳光（追加行动)。 乱数:".$tmp."<br>";
			$b->done --;
		}
	}
}

class DeathBargain extends LangClass {

	public function __construct() {
		$this->id = 283;
		$this->name = "死の契約";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 50;
		$this->tp = 50;
		$this->bodds = 40;
	}
	
	//起始函数，单体型
	public function start($a,$b,$atkid,$defid,$defer) {		
		
		$sk = clone $this;
		CalHelper::cost_cal($a[$atkid],$sk);
		$sk->action($a[$atkid],$defer,$defid);		
	}
	
	//行动函数 $f:来自哪组 $t:到哪组
	public function action($a,$b,$fp) {
		$_SESSION['show'] .= $a->name."向".$b->name."下达".$this->name."<br>";
		$this->pre_talk($a,$b);
		$tmp = mt_rand(1,100);
		if($this->bodds >= $tmp) {
			$b->selfid = $fp;
			$b->defafter_status[5]->on = 1;
			$_SESSION['show'] .= $b->name."接受了契约，契约将从其死后开始履行。乱数:".$tmp."<br>";
		} else {
			$_SESSION['show'] .= $b->name."拒绝了契约，".$a->name."失去下次行动机会(手动执行)。乱数:".$tmp."<br>";
			StatusHelper::all_down_20($a);
		}
	}
}

class HeroCrawler extends LangClass {

	public function __construct() {
		$this->id = 283;
		$this->name = "英雄狩り";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 80;
		$this->tp = 80;
	}
	
	//起始函数，单体型
	public function start($a,$b,$atkid,$defid,$defer) {		
		
		$sk = clone $this;
		CalHelper::cost_cal($a[$atkid],$sk);
		$sk->action($a[$atkid],$defer,$defid);		
	}
	
	//行动函数 $f:来自哪组 $t:到哪组
	public function action($a,$b,$fp) {
		$_SESSION['show'] .= $a->name."向".$b->name."发动".$this->name."<br>";
		if($this->pre_talk($a,$b) == 0) return 0;

		if($b->baselv <= 35) $sucodds = 10;
		elseif($b->baselv >= 36 && $b->baselv <= 60) $sucodds = 20;
		elseif($b->baselv >= 61 && $b->baselv <= 80) $sucodds = 25;
		elseif($b->baselv >= 81) $sucodds = 30;

		$tmp = mt_rand(1,100);
		if($sucodds >= $tmp) {
			if(in_array($b,$_SESSION['a'])) {
				$f = &$_SESSION['a'];
				$t = &$_SESSION['b'];				
			}
			else {
				$f = &$_SESSION['b'];
				$t = &$_SESSION['a'];				
			}
			$_SESSION['show'] .= $b->name."向往和".$a->name."并肩作战，加入了".$a->name."的阵营。乱数:".$tmp."<br>";
			$b->talked = 1;
			$b->atkafter_status[9]->on = 1;			
			$b->atkafter_status[9]->fp = $fp;
			$b->atkafter_status[9]->tp = count($t);
			$t[count($t)] = $b;
			$dummy = new Char;
			$dummy->hp = 0;
			$dummy->name = "占位";
			$dummy->isdummy = 1;
			$f[$fp] = $dummy;
		}
		else {
			$_SESSION['show'] .= $b->name."对".$a->name."的提议全无兴趣，当场拒绝（追加行动)。 乱数:".$tmp."<br>";
			$b->done --;
		}
	}
}

class SilentBargain extends LangClass {

	public function __construct() {
		$this->id = 284;
		$this->name = "静天の契り";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 40;
		$this->tp = 40;
		$this->bodds = 50;
	}
	
	//起始函数，单体型
	public function start($a,$b,$atkid,$defid,$defer) {		

		$sk = clone $this;
		CalHelper::cost_cal($a[$atkid],$sk);
		if($this->bodds >= mt_rand(1,100)) {
			$_SESSION['show'] .= $this->name."成功，全场生效。<br>";
			$c = array_merge($a,$b);
			foreach($c as $d) {
				$sk->action($a[$atkid],$d);
			}
		} else {
			$_SESSION['show'] .= $this->name."失败，只对己方生效。<br>";
			foreach($a as $d) {
				$sk->action($a[$atkid],$d);
			}
		}
	}
	
	//行动函数
	public function action($a,$b) {
		$_SESSION['show'] .= $a->name."发动".$this->name."<br>";
		if($_SESSION['T'] == 5) {
			StatusHelper::sbargain($b);
		} else {
			$_SESSION['show'] .= "当前并非静天，".$this->name."完全无效。<br>";
		}
	}
}

class DeathClaim extends LangClass {

	public function __construct() {
		$this->id = 594;
		$this->name = "死亡告知";			//技能名称
		$this->type = 10;				//组别		
	
		$this->hp = 0;			//消耗
		$this->sp = 80;
		$this->tp = 80;
		$this->bodds = 60;
	}
	
	//起始函数，单体型
	public function start($a,$b,$atkid,$defid,$defer) {		
		
		$sk = clone $this;
		CalHelper::cost_cal($a[$atkid],$sk);
		$sk->action($a[$atkid],$defer);
	}
	
	//行动函数 $f:来自哪组 $t:到哪组
	public function action($a,$b) {
		$_SESSION['show'] .= $a->name."向".$b->name."发动".$this->name."<br>";
		if($this->pre_talk($a,$b) == 0) return 0;
		$tmp = mt_rand(1,100);
		if($this->bodds >= $tmp) {
			$_SESSION['show'] .= "死兆星已悄然地降临到了".$b->name."头上...<br>";
			$b->atkafter_status[12]->on = 1;
		}
		else {
			$_SESSION['show'] .= $b->name."抵御住了死兆的侵袭。乱数:".$tmp."<br>";
		}
	}
}

?>
